import os

def file_name(file_dir,output_txt_path):
    L=[]
    f = open(output_txt_path, 'a')
    idx = 0
    for root, dirs, files in os.walk(file_dir):
        for file in files:
            if os.path.splitext(file)[1] == '.xml':
                # L.append(os.path.join(root, file))
                file=file.split(".xml")
                # L.append(file[0])
                # f.write('\n' + str(i))
                f.write('data/custom/images/'+ file[0] + '\n')
    f.close()
    # return L

if __name__=='__main__':
    table=file_name('test/Annotations/','test/train1.txt')
    print(table)